<script setup>
import DetailPanel from '@/components/detail-panel/detail-panel.vue'

import { storeToRefs } from 'pinia'
import useDetailStore from '@/stores/modules/detail'
import { computed } from 'vue'

const detailStore = useDetailStore()
const { getComment } = storeToRefs(detailStore)
const value = computed(() => {
  return getComment.value?.overall
})
</script>

<template>
  <div class="detail-comment">
    <DetailPanel title="热门评论" :more="`查看全部${getComment?.totalCount}条评论`">
      <div class="comment-inner">
        <div class="top">
          <div class="left">
            <div class="score">
              <div class="text">{{ getComment?.overall.toFixed(1) }}</div>
              <div class="line"></div>
            </div>
            <div class="info">
              <div class="title">{{ getComment?.scoreTitle }}</div>
              <div class="count">{{ getComment?.totalCount }}条评论</div>
              <div class="star">
                <van-rate v-model="value" color="#ff9645" size="12" readonly allow-half />
              </div>
            </div>
          </div>
          <div class="right">
            <template v-for="(item, index) in getComment?.subScores" :key="item">
              <span class="item">{{ item }}</span>
            </template>
          </div>
        </div>
        <div class="center">
          <template v-for="(item, index) in getComment?.commentTagVo" :key="index">
            <span class="item" :style="{ color: item.color, background: item.backgroundColor }">
              {{ item.text }}
            </span>
          </template>
        </div>
        <div class="bottom">
          <div class="user">
            <div class="avatar">
              <img :src="getComment?.comment.userAvatars" alt="" />
            </div>
            <div class="profile">
              <div class="name">{{ getComment?.comment.userName }}</div>
              <div class="date">{{ getComment?.comment.checkInDate }}</div>
            </div>
          </div>
          <div class="text">
            {{ getComment?.comment.commentDetail }}
          </div>
        </div>
      </div>
    </DetailPanel>
  </div>
</template>

<style lang="less" scoped>
.detail-comment {
  .comment-inner {
  }
  .top {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    justify-content: flex-end;
    .left {
      display: flex;
      align-items: flex-end;
      .score {
        display: flex;
        flex-direction: column;
        width: 65px;
        height: 100%;
        color: #333;
        position: relative;
        font-weight: 600;
        .text {
          font-size: 48px;
        }
        .line {
          width: 66px;
          height: 6px;
          background: linear-gradient(90deg, #fa8c1d, #fcaf3f);
          border-radius: 3px;
          margin-top: -10px;
        }
      }
      .info {
        margin-left: 19px;
        margin-bottom: -2px;
        font-size: 12px;
        color: #333;
        .count {
          margin: 3px 0;
          color: #999;
        }
      }
    }
    .right {
      display: flex;
      flex-wrap: wrap;
      flex: 1;
      justify-content: flex-end;
      margin-bottom: -3px;
      .item {
        margin-left: 5px;
        font-size: 12px;
        color: #666;
      }
    }
  }
  .center {
    display: flex;
    margin: 10px 0;
    flex-wrap: wrap;
    .item {
      padding: 3px 5px;
      margin-right: 8px;
      margin-top: 5px;
      border-radius: 8px;
      font-size: 12px;
    }
  }
  .bottom {
    padding: 10px;
    border-radius: 6px;
    background-color: #f7f9fb;
    .user {
      display: flex;
      .avatar {
        img {
          width: 32px;
          height: 32px;
          border-radius: 50%;
        }
      }
      .profile {
        margin-left: 8px;
        font-size: 14px;
        .date {
          margin-top: 3px;
          font-size: 12px;
          color: #999;
        }
      }
    }
    .text {
      font-size: 12px;
      line-height: 16px;
      color: #333;
      margin-top: 16px;
    }
  }
}
</style>
